#coding: utf-8

from db_base import Single
import csv
import types
import sys
class DepartModel(Single):

	@classmethod
	def extract_depart(cls):
		#return "aaaaaaaaaaaaaaaaaaaaa"
		reader=csv.DictReader(open('d:/python/epm6/epm_usrinfo_2012-12-29.csv','r'),delimiter=',',quotechar='@')

		arr={}
		for row in reader:
			dept=[]
			#return row['chname'].decode("gb2312")
			#return ','.join(row).decode('gb2312')
			#return row['pid']
		
#			dept.append(row['r_dept_1'].decode('gb2312'))
#			dept.append(row['r_dept_2'].decode('gb2312'))
#			dept.append(row['r_dept_3'].decode('gb2312'))
#			dept.append(row['r_dept_4'].decode('gb2312'))

			dept.append(row['r_dept_1'].decode('gb2312'))
			dept.append(row['r_dept_2'].decode('gb2312'))
			dept.append(row['r_dept_3'].decode('gb2312'))
			dept.append(row['r_dept_4'].decode('gb2312'))
		
			arr[row['pid']]=','.join(dept)


		dict2={}	
		for key in arr:
			#return arr[key]
			dict2[arr[key]]=key
		return  dict2
	
	